<?php
// +----------------------------------------------------------------------
// | NewThink [ Think More,Think Better! ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2018 http://www.newthink.cc All rights reserved.
// +----------------------------------------------------------------------
// | 版权所有：山西创泰网络科技有限公司
// +----------------------------------------------------------------------
// | Author: JiYun Date:2019-05-09 Time:11:08
// +----------------------------------------------------------------------

namespace app\common\model\system;

use app\common\model\BaseModel;
use Think\Db;

/**
 * Class SystemUserToken
 * @author JiYun On 2019/05/09
 * @package app\common\model\system
 */
final class SystemUserToken extends BaseModel
{
    protected $table = 'system_user_token';
    
    public function __construct()
    {
        parent::__construct();
    }
    
    /**
     * 写入Token
     * @author JiYun On 2019/05/09
     * @param array $data
     */
    public function saveData($data = [])
    {
        Db::name($this->table)
            ->data($data)
            ->insert();
    }
    
    /**
     * Token过期设置
     * @author JiYun On 2019/05/09
     * @param array $where
     * @param array $data
     * @return bool
     */
    public function expireToken($where = [], $data = [])
    {
        $result = true;
        
        try {
            Db::name($this->table)->where($where)->data($data)->update();
        } catch (\Exception $e) {
            $result = false;
        }
        
        return $result;
    }
}
